package org.example.rubbish.service.impl;


import org.example.rubbish.entity.Content;
import org.example.rubbish.mapper.ContentMapper;
import org.example.rubbish.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContentServiceImpl implements ContentService {
    @Autowired
    private ContentMapper contentMapper;

    @Override
    public Content createContent(Content content) {
        contentMapper.insert(content);
        return contentMapper.selectById(content.getId());
    }

    @Override
    public Content updateContent(Content content) {
        contentMapper.update(content);
        return contentMapper.selectById(content.getId());
    }

    @Override
    public Content getContentById(Long id) {
        return contentMapper.selectById(id);
    }

    @Override
    public List<Content> getAllContents() {
        return contentMapper.selectAll();
    }

    @Override
    public List<Content> getActiveContents() {
        return contentMapper.selectActiveContents();
    }
}